<template>
	<view>
		<view class="tabBox">
			<view>
				<text v-for="item in tagList" :key="item" @click="active=item" :class="active==item?'choose':''">
					{{item}}
				</text>
			</view>
			<view>
				<u-icon name='list' size='40rpx' @click='show=true' />
			</view>
		</view>
		<u-popup :show="show" :round="10" @close="show=false">
			<view class="popupTitle">
				<u-icon name='close' color='#fff' />
				<view>
					筛选条件
				</view>
				<u-icon name='close' @click='show=false' />
			</view>
			<view class="viewWidth">
				<u--form labelWidth='100%' labelPosition="top" :model="form" ref="uForm">

					<u-form-item label="工艺流程:" borderBottom>
						<view class="inputBox" @click="processShow=true">
							<view>
								{{form.process.name?form.process.name:'请选择工艺流程'}}
							</view>
							<view @click.stop='()=>{}'>
								<u-icon size='28rpx' color='#bbb' name='close-circle' v-if="form.process.id"
									@click.stop='form.process={name:"",id:""}' />
							</view>
						</view>
					</u-form-item>
					<u-form-item  label="关注:" borderBottom>
						<view class="inputBox" @click="customerShow=true">
							<view>
								{{form.customer.name?form.customer.name:'请选择关注浏览用户'}}
							</view>
							<view @click.stop='()=>{}'>
								<u-icon size='28rpx' color='#bbb' name='close-circle' v-if="form.customer.id"
									@click='form.customer={name:"",id:""}' />
							</view>
						</view>
					</u-form-item>


				</u--form>
			</view>
			<view class="viewWidth">
				<u-button @click='reload'>
					确认
				</u-button>
			</view>
		</u-popup>
		<root-portal>
			<u-picker keyName='title' :show="processShow" :columns="processList" @confirm='processConfirm'
				@cancel='processShow=false'></u-picker>
			<selectCustomer  :show='customerShow' @close='customerShow=false'
				@selectCustomer='selectCustomer' />
		</root-portal>
	</view>
</template>

<script>
	import selectCustomer from '@/components/selectCustomer';
	export default {
		components: {
			selectCustomer,
		},
		name: "filter",
		data() {
			return {
				tagList: ['正常', '排序'],
				active: '正常',
				show: false,
				form: {
					process: {
						name: '',
						id: ''
					},
					customer: {
						name: '',
						id: ''
					},
				},
				processShow: false,
				processList: [
					[]
				],
				customerShow: false,
			};
		},
		mounted() {
			this.getProcessList()
		},
		methods: {
			reload() {
				this.show = false
				this.$emit('reload', this.form)
			},
			processConfirm(e) {
				this.form.process.name = e.value[0].title
				this.form.process.id = e.value[0].id
				this.processShow = false
			},
			getProcessList() {
				this.$api.Process.List().then(res => {
					this.processList = [res.data.process]
				})
			},
			selectCustomer(item) {
				this.form.customer.name = item.nick_name
				this.form.customer.id = item.id
				this.customerShow = false
			},

		}
	}
</script>

<style lang="scss" scoped>
	.tabBox {
		padding:  0 30rpx 20rpx 0;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		
		>view {
			display: flex;
			flex-direction: row;
		}

		text {
			padding: 10rpx 20rpx;
			border-radius: 8rpx;
			background-color: #F2F2F2;
			font-size: 26rpx;
			margin-right: 20rpx;
		}

		.choose {
			color: #fff;
			background-color: rgb(57, 117, 198);
		}
	}

	.viewWidth {
		width: 92vw;
		margin: 10rpx auto;
	}
</style>